package com.government.web.controller.member;


import cn.hutool.core.date.DateUtil;
import com.government.common.core.controller.BaseController;
import com.government.common.core.domain.AjaxResult;
import com.government.common.core.domain.entity.SysUser;
import com.government.common.core.domain.model.LoginUser;
import com.government.member.domain.VipInfo;
import com.government.member.domain.VipOrder;
import com.government.member.service.VipInfoService;
import com.government.member.service.VipOrderService;
import com.government.member.vo.VipUpgrade;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


import java.util.List;


/**
 * vip相关Controller
 *
 * @author system
 * @date 2023-09-18
 */
@RestController
@RequestMapping("/vip")
public class VipInfoController extends BaseController {
    @Autowired
    private VipInfoService vipInfoService;

    @Autowired
    private VipOrderService vipOrderService;

    /**
     * 查询vip卡信息列表
     */
    @GetMapping("/vipInfo/list")
    public AjaxResult list() {
        List<VipInfo> list = vipInfoService.selectVipInfoList();
        return AjaxResult.success(list);
    }

    /**
     * 查询vip订单列表
     */
    @GetMapping("/vipOrder/list")
    public AjaxResult vipOrderList() {

        LoginUser loginUser = getLoginUser();
        SysUser user = loginUser.getUser();
        List<VipOrder> list = vipOrderService.selectOrderListByUserId(user.getUserId());
        for (VipOrder vipOrder : list) {
            vipOrder.setPayTimeStr(DateUtil.formatDateTime(vipOrder.getPayTime()));
        }
        return AjaxResult.success(list);
    }

//    /**
//     * vip升级
//     */
//    @GetMapping("/vipOrder/vipUpgrade")
//    public AjaxResult vipUpgrade() {
//
//        VipUpgrade vipUpgrade = vipOrderService.vipUpgrade();
//
//        return AjaxResult.success(vipUpgrade);
//    }

}
